package com.px.lovepath.ui.home;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;

import com.px.lovepath.R;
import com.px.lovepath.ui.general.LoveActivity;
import com.px.lovepath.ui.home.scrollview.MenuHorizontalScrollView;
import com.px.lovepath.ui.home.scrollview.SizeCallBackForMenu;

public class HomeActivity extends LoveActivity {

	private MenuHorizontalScrollView mScrollView;
	private View[] mChildren;
	// 右侧
	private View mContentView;
	// 展开菜单的button
	private View mMenuView;
	// 左侧
	private View mSetting;
	private ContentController mRightController;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.home__home_view);
		mScrollView = (MenuHorizontalScrollView) findViewById(R.id.home__home_view__scroll_view);
		mContentView = LayoutInflater.from(this).inflate(R.layout.home__home_content_view, null);
		mMenuView = mContentView.findViewById(R.id.home__home_view__setting);
		mMenuView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				mScrollView.clickMenu();
			}
		});
		View leftView = new View(this);
		leftView.setBackgroundColor(Color.TRANSPARENT);
        mChildren = new View[]{leftView, mContentView};
        mSetting = (View) findViewById(R.id.home__home_view__setting);
        mScrollView.initViews(mChildren, new SizeCallBackForMenu(mMenuView), mSetting);
        mScrollView.setMenuView(mMenuView);
        
        mRightController = new ContentController(this, mContentView);
	}
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK) {
			mRightController.loadData();
		}
	}
	
}